<script>
  let ev = new Event("promise");
  window.addEventListener("promise", () => {
    fnB();
  });

  function fnA() {
    setTimeout(() => {
      console.log("请求A完成");
      window.dispatchEvent(ev);
    }, 1000);
  }
  function fnB() {
    setTimeout(() => {
      console.log("请求B完成");
    }, 500);
  }
  fnA();
</script>
